package com.ljh.mall.order.utils;

import com.alibaba.fastjson.JSON;
import com.ljh.common.constant.OrderConstant;
import com.ljh.common.dto.SeckillOrderDto;
import com.ljh.mall.order.service.OrderService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author ：刘剑鸿
 * @date ：Created in 2023/5/25 21:24
 * @description：
 * @modified By：
 * @version: $
 */
@RocketMQMessageListener(topic = OrderConstant.ROCKETMQ_SECKILL_ORDER_TOPIC,consumerGroup = "test")
@Component
public class SeckillOrderConsumer implements RocketMQListener<String> {
    @Autowired
    OrderService orderService;

    @Override
    public void onMessage(String message) {
        // 订单关单的逻辑实现
        System.out.println("订单关单的逻辑实现"+message);
        SeckillOrderDto seckillOrderDto = JSON.parseObject(message, SeckillOrderDto.class);
        orderService.quickCreateOrder(seckillOrderDto);
    }
}
